<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@ include file="/html/library/init.jsp" %>

<%@page import="com.liferay.portal.kernel.dao.search.ResultRow"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>

<%
	ResultRow row = (ResultRow) request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
	Book book = (Book) row.getObject();
	
	PortletURL editBookUrl = renderResponse.createRenderURL();
	editBookUrl.setParameter("jspPage", "/html/library/edit-book.jsp");
	editBookUrl.setParameter("bookId", String.valueOf(book.getBookId()));
	
	PortletURL detailBookUrl = renderResponse.createRenderURL();
	detailBookUrl.setWindowState(LiferayWindowState.EXCLUSIVE);
	detailBookUrl.setParameter("jspPage", "/html/library/details.jsp");
	detailBookUrl.setParameter("bookId", String.valueOf(book.getBookId()));
	
	String popup = "javaScript:popup('"+ detailBookUrl.toString()+"');";	
	
%>

<liferay-ui:icon-menu>
	<liferay-ui:icon image="edit" message="Edit Book" url="<%= editBookUrl.toString() %>" />
	<liferay-ui:icon image="view" message="View Details" url="<%= popup %>" />
</liferay-ui:icon-menu>

<aui:script>

Liferay.provide(
			window,
			'popup',
			function(url) {
				var A = AUI();
	
				var data = {};
	
				var dialog = new A.Dialog(
					{
						centered: true,
						destroyOnClose: true,
						draggable: true,
						height: 330,
						width: 343,
						resizable: false,
						modal: true,
						title: 'Book Details'
					}
					).render();
						dialog.plug(
							A.Plugin.IO,
							{
								data: data,
								uri: url
							}
						);
				},
			['aui-dialog', 'aui-io']
	);


</aui:script>

